<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
</head>
<body>
    <script>
        // promise就是可以以同步的方式去写异步
        var url='https://api.douban.com/v2/book/search?q=三体&count=1';
        var promise=new Promise((resolve,reject)=>{
            $.ajax({
                url,
                dataType:"jsonp",
                success(res){
                    resolve(res);
                },
                error(err){
                    regect(err);
                }
            })
        })
        promise.then(res=>{
            console.log(res);
        }),err=>{
            console.log(err.status);
        }
        </script>
</body>
</html>